<template>
<div class="fileUpload">
  <el-upload
    class="upload-demo"
    action="/fileUploads"
    :limit="3"
    :file-list="fileList"
    :http-request="workFileUpload">
    <el-button slot="trigger" size="small" type="primary">选取文件</el-button>

  </el-upload>
</div>
</template>

<script>
import {workFileUpload} from "../api/api";

export default {
  name: "FileUpload",
  data() {
    return {
      fileList:[]
    }
  },
  methods: {
    async workFileUpload(file){
      var formData = new FormData();
      formData.append("file",file.file)
      var newVar = await workFileUpload(formData);
      alert("数据上传成功")
    }
  }
};
</script>

<style scoped>
.fileUpload{
  width: 500px;
  height: 500px;

}
</style>